import {createRouter, createWebHashHistory} from 'vue-router'
import {useStore} from 'vuex';

const routes = [
   {
      path: '/',
      name: 'Layout',
      component: () => import('../components/Layout.vue'),
      redirect: '/home',
      // 添加路由
      children: [
          // 将icon参数更换成ElementPlus对应的图标名称即可
         {
            path: '/home',
            name: 'Home',
            component: () => import('../views/home.vue'),
            meta: {title: '首页', icon: 'Menu'}
         },
         {
            path: '/admin/user',
            name: 'admin-user',
            component: () => import('../views/admin/user/index.vue'),
            meta: {title: '用户管理', icon: 'User'}
         },
         {
            path: '/admin/project',
            name: 'admin-project',
            component: () => import('../views/admin/project/index.vue'),
            meta: {title: '项目管理', icon: 'Message'}
         },
         {
            path: '/admin/task',
            name: 'admin-task',
            component: () => import('../views/admin/task/index.vue'),
            meta: {title: '任务管理', icon: 'Notebook'}
         },
         {
            path: '/admin/admin',
            name: 'admin-admin',
            component: () => import('../views/admin/admin/index.vue'),
            meta: {title: '管理员管理', icon: 'Flag'}
         }
      ]
   },
   {
      path: '/admin/center',
      name: 'admin-center',
      component: () => import('../views/admin/admin/center.vue'),
      meta: {title: '个人中心'}
   },
   {
      path: '/login',
      name: 'Login',
      component: () => import('../views/login/index.vue'),
      meta: {title: '登录'}
   },
   {
      path: '/*',
      redirect: '/',
   },
]
const router = createRouter({
   history: createWebHashHistory(),
   routes
})

router.afterEach((to) => {
   document.title = to.meta.title;
})
export default router